<!--资产管理员添加页面-->

<template>
  <div style="margin-top: 60px;margin-left:330px;width: 300px;height: 500px;border: 0px solid red;" >
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
      <el-form-item label="组织结构名" prop="orgName">
        <el-input v-model="ruleForm.orgName"></el-input>
      </el-form-item>
      <el-form-item label="所属父类组织" prop="fatherOrg">
        <el-input v-model="ruleForm.fatherOrg"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
        <el-button @click="resetForm('ruleForm')">重置</el-button>
      </el-form-item>
    </el-form>
  </div>

</template>

<script>
export default {
  data() {
    return {
      category:null,
      ruleForm: {
        orgName: '',
        fatherOrg: '',
      },
      rules: {
        orgName: [
          { required: true, message: '请输入组织名', trigger: 'blur' }
        ],
        fatherOrg: [
          { required: true, message: '请输入父类组织名', trigger: 'blur' }
        ],

      }
    };
  },
  methods: {
    submitForm(formName) {
      const _this = this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          axios.post('http://localhost:8181/tbAssertOrg/save',_this.ruleForm).then(function (resp) {
            if(resp.data.code == 0){
              _this.$alert(_this.ruleForm.orgName+'添加成功', '', {
                confirmButtonText: '确定',
                callback: action => {
                  _this.$router.push('/searchOrg3')
                }
              });
            }
          })
        }
      });
    },
    resetForm(formName) {
      //重置表单
      this.$refs[formName].resetFields();
    }
  }
}
</script>
